/*
 * @Author: your name
 * @Date: 2020-06-06 17:32:14
 * @LastEditTime: 2020-06-28 16:21:53
 * @LastEditors: your name
 * @Description: In User Settings Edit
 * @FilePath: \crm\lib\pages\index_page.dart
 */ 

import 'package:crm/components/ui/bubble_bottom_bar.dart';
import 'package:crm/pages/about/about_page.dart';
import 'package:crm/pages/business/business_page.dart';
import 'package:crm/pages/customer/customer_page.dart';
import 'package:crm/pages/home/home_page.dart';
import 'package:crm/provider/currentIndex.dart';
import 'package:crm/utils/double_tap_back_exit_app.dart';
import 'package:crm/utils/theme_utils.dart';
import 'package:flutter/material.dart';

import 'package:flutter/cupertino.dart';
import 'package:flutter_screenutil/screenutil.dart';
import 'package:provider/provider.dart';
class IndexPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    ScreenUtil.init(context, width: 750, height: 1334, allowFontScaling: true);
    return DoubleTapBackExitApp(
        child: Selector<CurrentIndexProvider, CurrentIndexProvider>(
      selector: (context, provider) => provider,
      shouldRebuild: (pre, next) => true,
      builder: (context, value, child) {
        return Container(
          child: Scaffold(
            bottomNavigationBar: BubbleBottomBar(
                opacity: 0.2,
                currentIndex: value.currentIndex,
                onTap: (int index) {
                  Provider.of<CurrentIndexProvider>(context, listen: false)
                      .changeIndex(index);
                },
                borderRadius: BorderRadius.vertical(top: Radius.circular(16)),
                elevation: 8,
                items: <BubbleBottomBarItem>[
                  BubbleBottomBarItem(
                      backgroundColor: Colors.red,
                      icon: Icon(Icons.home,
                          color: ThemeUtils.getIconColor(context)),
                      activeIcon: Icon(Icons.home, color: Colors.red),
                      title: Text("首页")),
                  BubbleBottomBarItem(
                      backgroundColor: Colors.deepPurple,
                      icon: Icon(Icons.dashboard,
                          color: ThemeUtils.getIconColor(context)),
                      activeIcon:
                          Icon(Icons.dashboard, color: Colors.deepPurple),
                      title: Text("客户")),
                  BubbleBottomBarItem(
                      backgroundColor: Colors.indigo,
                      icon: Icon(Icons.language,
                          color: ThemeUtils.getIconColor(context)),
                      activeIcon: Icon(Icons.language, color: Colors.indigo),
                      title: Text("商机")),
                  BubbleBottomBarItem(
                      backgroundColor: Colors.green,
                      icon: Icon(Icons.account_circle,
                          color: ThemeUtils.getIconColor(context)),
                      activeIcon:
                          Icon(Icons.account_circle, color: Colors.green),
                      title: Text("我的"))
                ]),
            body: IndexedStack(
              index: value.currentIndex,
              children: <Widget>[
                HomePage(),
                CustomerPage(),
                BusinessPage(),
                AboutPage()
              ],
            ),
          ),
        );
      },
    ));
  }
}
